﻿using System;

namespace demo5
{
    class Program
    {
        static void Main(string[] args)
        {
            // 算术运算符
            int a = 21;
            int b = 10;
            int c;

            c = a + b;
            Console.WriteLine("Line 1 - c 的值是 {0}", c);
            c = a - b;
            Console.WriteLine("Line 2 - c 的值是 {0}", c);
            c = a * b;
            Console.WriteLine("Line 3 - c 的值是 {0}", c);
            c = a / b;
            Console.WriteLine("Line 4 - c 的值是 {0}", c);
            c = a % b;
            Console.WriteLine("Line 5 - c 的值是 {0}", c);
            c = a++;
            Console.WriteLine("Line 6 - c 的值是 {0}", c);
            c = a--;
            Console.WriteLine("Line 7 - c 的值是 {0}", c);
            Console.ReadLine();

            // 关系运算符
            int d = 21;
            int e = 10;

            if (d == e)
            {
                Console.WriteLine("Line 1 - d 等于 e");
            }
            else
            {
                Console.WriteLine("Line 1 - d 不等于 e");
            }
            if (d < e)
            {
                Console.WriteLine("Line 2 - d 小于 e");
            }
            else
            {
                Console.WriteLine("Line 2 - d 不小于 e");
            }
            if (d > e)
            {
                Console.WriteLine("Line 3 - d 大于 e");
            }
            else
            {
                Console.WriteLine("Line 3 - d 不大于 e");
            }

            /* 改变 d 和 e 的值 */
            d = 5;
            e = 20;
            if (d <= e)
            {
                Console.WriteLine("Line 4 - d 小于或等于 e");
            }
            if (e >= d)
            {
                Console.WriteLine("Line 5 - e 大于或等于 d");
            }
            Console.ReadLine();

            // 逻辑运算符
            bool f = true;
            bool g = true;

            if (f && g)
            {
                Console.WriteLine("Line 1 - 条件为真");
            }
            if (f || g)
            {
                Console.WriteLine("Line 2 - 条件为真");
            }

            /* 改变 f 和 g 的值 */
            f = false;
            g = true;
            if (f && g)
            {
                Console.WriteLine("Line 3 - 条件为真");
            }
            else
            {
                Console.WriteLine("Line 3 - 条件不为真");
            }
            if (!(f && g))
            {
                Console.WriteLine("Line 4 - 条件为真");
            }
            Console.ReadLine();

            //位运算符
            int h = 60; /* 60 = 0011 1100 */
            int i = 13; /* 13 = 0000 1101 */
            int j = 0;

            j = h & i; /* 12 = 0000 1100 */
            Console.WriteLine("Line 1 - j 的值是 {0}", j);

            j = h | i; /* 61 = 0011 1101 */
            Console.WriteLine("Line 2 - j 的值是 {0}", j);

            j = h ^ i; /* 49 = 0011 0001 */
            Console.WriteLine("Line 3 - j 的值是 {0}", j);

            j = ~h; /*-61 = 1100 0011 */
            Console.WriteLine("Line 4 - j 的值是 {0}", j);

            j = h << 2; /* 240 = 1111 0000 */
            Console.WriteLine("Line 5 - j 的值是 {0}", j);
            j = h >> 2; /* 15 = 0000 1111 */
            Console.WriteLine("Line 6 - j 的值是 {0}", j);
            Console.ReadLine();
        }
    }
}
